package com.cinema;

import java.io.IOException;
import javax.servlet.http.*;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

@SuppressWarnings("serial")
public class CinemaBK2011Servlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		UserService userService = UserServiceFactory.getUserService();
		User user = userService.getCurrentUser();
		if(user != null){
			String nick = user.getNickname();
			resp.setContentType("text/plain");
			resp.getWriter().println("Hello " + nick);
		}else
			resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
	}
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException{
		doPost(req, resp);
	}
}
